Midrasch zu Könige I 9:4
וְאַתָּ֞ה אִם־תֵּלֵ֣ךְ לְפָנַ֗י כַּאֲשֶׁ֨ר הָלַ֜ךְ דָּוִ֤ד אָבִ֙יךָ֙ בְּתָם־לֵבָ֣ב וּבְיֹ֔שֶׁר לַעֲשׂ֕וֹת כְּכֹ֖ל אֲשֶׁ֣ר צִוִּיתִ֑יךָ חֻקַּ֥י וּמִשְׁפָּטַ֖י תִּשְׁמֹֽר׃
Und was dich betrifft, wenn du vor mir wandelst, wie David, dein Vater, in Integrität des Herzens und in Aufrichtigkeit wandelt, um nach allem zu tun, was ich dir geboten habe, und meine Satzungen und meine Verordnungen einzuhalten;
Sifrei Devarim
R. Chanina b. Gamliel says: It is written (I Kings 3:13) "And also what you (Solomon) did not ask I have granted you — even riches and honor": I have granted you even what is not stipulated in the Torah. Shall I not then grant you what is written in the Torah (i.e., length of days, etc.) Only on condition that you observe the Torah, viz. (Ibid. 14) "If you (Solomon) walk in My ways to keep My statutes and My mitzvoth, as did your father David, then I shall prolong your days," and (Ibid. 9:4) "And as for you, if you walk before Me as your father David did, with wholeheartedness and uprightness, to do according to all that I have commanded you, to keep My statutes and My judgments, etc."
Ask RabbiBookmarkShareCopy